package com.guyaning.deyson_ec.ec.main.sort.content;

import android.support.v7.widget.AppCompatImageView;

import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.guyaning.deyson_core.core.ui.image.GlideApp;
import com.guyaning.deyson_ec.ec.R;

import java.util.List;

/**
 * Created by Administrator on 2018/6/28.
 */

public class SectionAdapter extends BaseSectionQuickAdapter<SectionBean,BaseViewHolder> {

    public SectionAdapter(int layoutResId, int sectionHeadResId, List<SectionBean> data) {
        super(layoutResId, sectionHeadResId, data);
    }

    @Override
    protected void convertHead(BaseViewHolder helper, SectionBean item) {

        helper.setText(R.id.header,item.header);

        helper.setVisible(R.id.more,item.ismIsMore());

        helper.addOnClickListener(R.id.more);
    }

    @Override
    protected void convert(BaseViewHolder helper, SectionBean item) {

        int goodsId = item.t.getmGoodsId();

        helper.setText(R.id.tv,item.t.getmGoodsName());

        AppCompatImageView imageView = helper.getView(R.id.iv);

        GlideApp.with(mContext)
                .load(item.t.getmGoodsThumb())
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .dontAnimate()
                .into(imageView);
    }
}
